﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Heavy_Metals
{
    public partial class DataChart : Form
    {
        public DataChart()
        {
            InitializeComponent();
        }
        public double[] data1 = { 23, 24, 22, 23, 20, 22, 21, 19, 22, 23, 26, 22, 24,24,22 };
        public double[] data2 = { 5,2,4,2,4,2,3,1,4,5,2,4,3,4,2};
        public double[] data3 = { 11,12,13,15,13,15,13,16,14,12,16,14,13,15,13};
        public double[] data4 = { 20,19,19,17,19,18,22,19,18,21,22,18,24,23,19};
        public double[] data5 = { 28,24,26,23,25,27,26,28,22,23,25,23,27,26,20};

        public Pen p1 = new Pen(Color.YellowGreen,2);
        public Pen p2 = new Pen(Color.Aquamarine, 2);
        public Pen p3 = new Pen(Color.WhiteSmoke, 2);
        public Pen p4 = new Pen(Color.Gold, 2);
        public Pen p5 = new Pen(Color.HotPink, 2);

        public DrawCurves dc = new DrawCurves();
        private void timerClock_Tick(object sender, EventArgs e)
        {

        }

        private void DataChart_Load(object sender, EventArgs e)
        {

        }

        private void panelRealtime_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Pen p = new Pen(Color.Blue, 2);
            dc.DrawCoordinate(g, p, 40, 220, 600, 210, 20, 20, 2.5, 5.0);


        }

        private void panelHistory_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Pen p = new Pen(Color.Blue, 2);
            dc.DrawCoordinate(g, p, 40, 220, 600, 210, 20, 20, 2.5, 5.0);
        }

        private void buttonRealTime_Click(object sender, EventArgs e)
        {
            //清空以前的绘图
            this.panelRealtime.Enabled = false;
            this.panelRealtime.Enabled = true;
           // Graphics g = this.panelRealtime.CreateGraphics();
            //Pen p = new Pen(Color.Blue, 2);
           // dc.DrawCoordinate(g, p, 40, 220, 600, 210, 20, 20, 2.5, 5.0);
//
            Graphics g1 = this.panelRealtime.CreateGraphics();
            double perPicelY = 5.0 / 20;
            if (this.checkBoxPb.Checked)
            {
                dc.DrawCurve(g1, p1, "", new Point(0, 0), 40, 220, perPicelY, 20, data1);
            }
            if (this.checkBoxAs.Checked)
            {
                dc.DrawCurve(g1, p2, "", new Point(0, 0), 40, 220, perPicelY, 20, data2);
            }
            if (this.checkBoxHg.Checked)
            {
                dc.DrawCurve(g1, p3, "", new Point(0, 0), 40, 220, perPicelY, 20, data3);
            }
            if (this.checkBoxCr.Checked)
            {
                dc.DrawCurve(g1, p4, "", new Point(0, 0), 40, 220, perPicelY, 20, data4);
            }
            if (this.checkBoxCd.Checked)
            {
                dc.DrawCurve(g1, p5, "", new Point(0, 0), 40, 220, perPicelY, 20, data5);
            }

        }

        private void buttonHistory_Click(object sender, EventArgs e)
        {
            //清空以前的绘图
            this.panelHistory.Enabled = false;
            this.panelHistory.Enabled = true;
            // Graphics g = this.panelRealtime.CreateGraphics();
            //Pen p = new Pen(Color.Blue, 2);
            // dc.DrawCoordinate(g, p, 40, 220, 600, 210, 20, 20, 2.5, 5.0);
            //
            Graphics g1 = this.panelHistory.CreateGraphics();
            double perPicelY = 5.0 / 20;
            if (this.checkBoxPb2.Checked)
            {
                dc.DrawCurve(g1, p1, "", new Point(0, 0), 40, 220, perPicelY, 20, data1);
            }
            if (this.checkBoxAs2.Checked)
            {
                dc.DrawCurve(g1, p2, "", new Point(0, 0), 40, 220, perPicelY, 20, data2);
            }
            if (this.checkBoxHg2.Checked)
            {
                dc.DrawCurve(g1, p3, "", new Point(0, 0), 40, 220, perPicelY, 20, data3);
            }
            if (this.checkBoxCr2.Checked)
            {
                dc.DrawCurve(g1, p4, "", new Point(0, 0), 40, 220, perPicelY, 20, data4);
            }
            if (this.checkBoxCd2.Checked)
            {
                dc.DrawCurve(g1, p5, "", new Point(0, 0), 40, 220, perPicelY, 20, data5);
            }
        }
    }
}
